﻿@model PagedList.IPagedList<DoAnWebsite.Models.News>
@using System.Globalization 
@foreach (var item in Model)
{
    <div class="searchResult">
        <div class="Titlesearch">
            @Html.ActionLink(@item.Title, "NewsDetail", "Home", new { id = @item.NewsId }, null)
        </div>
        <div class="ContentSearch">
            <div>@Html.Raw(@item.Content)</div>                        
        </div>
    </div>
}
<script>
    $(document).ready(function () {
        var page = @ViewBag.pageNumber;
        var id = "cmpage" + page;
        $(".pagingbar a").removeClass("active");
        $('#' + id).addClass('cmpageActive');
    });
</script>
@if (Model.PageCount > 1)
{
    <div class="pagingbar">
        @Ajax.ActionLink("Đầu", "SearchbyTagPartial", new {page = 1}, new AjaxOptions {UpdateTargetId = "resultsearch"})
        @Ajax.ActionLink("<", "SearchbyTagPartial", new {page = Model.PageNumber - 1}, new AjaxOptions {UpdateTargetId = "resultsearch"})
        @for (int i = 1; i <= Model.PageCount; i++)
        {
            var page = i.ToString(CultureInfo.InvariantCulture);
            @Ajax.ActionLink(page, "SearchbyTagPartial", new {page = i}, new AjaxOptions {UpdateTargetId = "resultsearch"}, new {@id = "cmpage" + page})
        }
        @Ajax.ActionLink(">", "SearchbyTagPartial", new {page = Model.PageNumber + 1}, new AjaxOptions {UpdateTargetId = "resultsearch"})
        @Ajax.ActionLink("Cuối", "SearchbyTagPartial", new {page = Model.PageCount}, new AjaxOptions {UpdateTargetId = "resultsearch"})
    </div>
}